package com.example.huawei.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.huawei.system.entity.UserCar;
import com.example.huawei.system.mapper.UserCarMapper;
import com.example.huawei.system.service.UserCarService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author 15097789205
 * @description 针对表【user_car】的数据库操作Service实现
 * @createDate 2025-07-07 11:01:29
 */
@Service
public class UserCarServiceImpl extends ServiceImpl<UserCarMapper, UserCar>
        implements UserCarService {

    @Override
    public List<UserCar> queryList(UserCar userCar) {
        List<UserCar> list = baseMapper.queryList(userCar);
        long now = new Date().getTime();
        list.forEach(item -> {
            item.setCarAge(((now - item.getBuyCarTime().getTime()) / (24L * 60 * 60 * 1000 * 365)) + "年");
        });
        return list;
    }
}




